/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package utfpr.cp.model;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import utfpr.cp.crawler.Util;

/**
 *
 * @author Adriano_2
 */
@Entity
public class URLTarget implements Serializable {
    private static final long serialVersionUID = 1L;
   
    @Id
    @Column(length = 1000, unique = true)
    private String url;
    
    @Column(nullable=true)
    private boolean started;
    @Column(nullable=true)
    private boolean finished;
    @Column(nullable=true)
    private boolean hasError;

    public URLTarget() {
        url = "";
        started = false;
        finished = false;
        hasError = false;
    }

    URLTarget(String url) {
        this.url = url;
        started = false;
        finished = false;
        hasError = false;
    }

    /**
     * @return the url
     */
    public String getUrl() {
        return url;
    }

    /**
     * @param url the url to set
     */
    public void setUrl(String url) {
        this.url = Util.maxLength(url, 1000);
    }
    
    public boolean exist() {
        return !url.isEmpty();
    }

    /**
     * @return the started
     */
    public boolean isStarted() {
        return started;
    }

    /**
     * @param started the started to set
     */
    public void setStarted(boolean started) {
        this.started = started;
    }

    /**
     * @return the finished
     */
    public boolean isFinished() {
        return finished;
    }

    /**
     * @param finished the finished to set
     */
    public void setFinished(boolean finished) {
        this.finished = finished;
    }

    /**
     * @return the hasError
     */
    public boolean hasError() {
        return hasError;
    }

    /**
     * @param hasError the hasError to set
     */
    public void setError(boolean hasError) {
        this.hasError = hasError;
    }
}
